From: Florian Müllner Date: Fri, 17 Jan 2020 16:26:08 +0000 (+0100) Subject: dateMenu: Indicate when do-not-disturb is on X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~781^2^2~142 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=9e9f3ff6b41000c09ddfb0d59a95ad0bc54102df;p=gnome-shell.git dateMenu: Indicate when do-not-disturb is on When do-not-disturb is enabled, non-critical notifications will not be shown as banners. It therefore makes sense to indicate that state to the user, so they don't accidentally miss notifications. https://gitlab.gnome.org/GNOME/gnome-shell/issues/239 --- diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js index 9bdd2c4d1..63bcbdf5e 100644 --- a/js/ui/dateMenu.js +++ b/js/ui/dateMenu.js @@ -432,7 +432,6 @@ var MessagesIndicator = GObject.registerClass( class MessagesIndicator extends St.Icon { _init() { super._init({ - icon_name: 'message-indicator-symbolic', icon_size: 16, visible: false, y_expand: true, @@ -440,6 +439,13 @@ class MessagesIndicator extends St.Icon { }); this._sources = []; + this._count = 0; + this._doNotDisturb = false; + + this._settings = new Gio.Settings({ + schema_id: 'org.gnome.desktop.notifications', + }); + this._settings.connect('changed::show-banners', this._sync.bind(this)); Main.messageTray.connect('source-added', this._onSourceAdded.bind(this)); Main.messageTray.connect('source-removed', this._onSourceRemoved.bind(this)); @@ -447,6 +453,11 @@ class MessagesIndicator extends St.Icon { let sources = Main.messageTray.getSources(); sources.forEach(source => this._onSourceAdded(null, source)); + + this.connect('destroy', () => { + this._settings.run_dispose(); + this._settings = null; + }); } _onSourceAdded(tray, source) { @@ -463,9 +474,17 @@ class MessagesIndicator extends St.Icon { _updateCount() { let count = 0; this._sources.forEach(source => (count += source.unseenCount)); - count -= Main.messageTray.queueCount; + this._count = count - Main.messageTray.queueCount; - this.visible = count > 0; + this._sync(); + } + + _sync() { + let doNotDisturb = !this._settings.get_boolean('show-banners'); + this.icon_name = doNotDisturb + ? 'notifications-disabled-symbolic' + : 'message-indicator-symbolic'; + this.visible = doNotDisturb || this._count > 0; } });